home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectSound / PlaySound / readme.txt < prev    next >
Encoding:
Text File  |  2001-10-10  |  2.7 KB  |  67 lines

  1. //-----------------------------------------------------------------------------
  2. // 
  3. // Sample Name: PlaySound Sample
  4. // 
  5. // Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
  6. // 
  7. //-----------------------------------------------------------------------------
  8.  
  9.  
  10. Description
  11. ===========
  12.   The PlaySound sample shows how to play a wave file in a DirectSound 
  13.   secondary buffer.
  14.     
  15. Path
  16. ====
  17.   Source: DXSDK\Samples\Multimedia\DSound\PlaySound
  18.  
  19.   Executable: DXSDK\Samples\Multimedia\DSound\Bin
  20.  
  21. User's Guide
  22. ============
  23.   Load a wave file by clicking Sound File. Select Loop Sound if you want 
  24.   it to play repeatedly. Click Play.
  25.  
  26. Programming Notes
  27. =================
  28.   The basic tasks write an application that supports DirectSound are as follows:
  29.  
  30.   * Set up DirectSound: 
  31.      1. Call DirectSoundCreate to create a IDirectSound object
  32.      2. Call IDirectSound::SetCooperativeLevel to set the cooperative level.
  33.      3. Set the primary buffer format.  This sample calls 
  34.         DSUtil_SetPrimaryBufferFormat() to do just this. 
  35.        
  36.   * Load a wav file into a DirectSound buffer:
  37.      1. Read the wav file to get the wav file size, and the wav format 
  38.         in the format a WAVEFORMATEX structure.
  39.      2. If the wav file of reasonable size, then create a DirectSound buffer 
  40.         big enough to hold the entire wav file, and set it's format to
  41.         that of the wav file.  If the wav file large, then see the 
  42.         StreamData sample for information on how to stream data into a 
  43.         DirectSound buffer. 
  44.      3. Next, fill the DirectSound buffer with wav data.  A pointer into the 
  45.         buffer can be obtained by calling IDirectSoundBuffer::Lock.  After the 
  46.         memory has been copied, call IDirectSoundBuffer::Unlock.
  47.  
  48.   * Play or stop the DirectSound buffer:
  49.      1. First, check to see if the buffer was not lost.  If it was, then it will 
  50.         need to be restored.
  51.      2. To play the buffer call IDirectSoundBuffer::Play.
  52.      3. To stop the buffer call IDirectSoundBuffer::Stop.
  53.      
  54.   * To check to see if the sound stopped:
  55.      It may be useful to tell if a DirectSound buffer stopped playing.  An easy 
  56.      way to do this would be to set a timer to trigger every so often.  When the 
  57.      timer message is sent, call IDirectSoundBuffer::GetStatus to see if the 
  58.      DSBSTATUS_PLAYING is set.  If it is not, then the sound has stopped. 
  59.      
  60.   * Handle restoring a DirectSound buffer:
  61.      First call IDirectSoundBuffer::Restore. Next, fill the buffer with sound again 
  62.      since the sound data was lost from when the buffer was lost.  
  63.        
  64.   * Free DirectSound:
  65.      Simply call Release() on all the DirectSound objects that were created.
  66.   
  67.